<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>轮播图</title>
    <script>
        let number = 1;
        // 修改图片属性
        function f() {
            number++;
            // 控制图片
            if (number > 3){
                number =1 ;
            }
            let img = document.getElementById("img");
            img.src = "img/banner_"+number+".jpg";
        }
        // 循环定时--轮播
        setInterval(f,2000);


    </script>
</head>
<body>
    <input type="button" id="back" value="后退">

    <img id="img" src="img/banner_1.jpg" width="100%">

<script>

    // 历史记录
    let back = document.getElementById("back");
    back.onclick = function(){
        // history.back()
        history.go(-1);
    }

</script>
</body>
</html>